import vuexDeepUpdate from '@/utils/vuexDeepUpdate.js'

const modules = {}
const excludedFiles = new Set([
	'./index.js',
	// #ifndef APP 
	'./permission.js'
	// #endif 
])

const files = require.context('./', false, /\.js$/)

files.keys().forEach(key => {
	if (excludedFiles.has(key)) return

	const module = files(key).default
	module.mutations = {
		...module.mutations,
		$setStore: vuexDeepUpdate
	}

	const moduleName = key.replace(/^\.\/(.*)\.js$/, '$1')
	modules[moduleName] = module
})

export default modules